package gdut.stream.middle;

import java.util.*;
import java.util.stream.Stream;

public class BuildStream {
    public static void main(String[] args) {
//        创建stream流
//        单列集合创建stream流,使用(集合对象).stream()
        ArrayList<Integer> integersList = new ArrayList<>();
        Stream<Integer> integerStream = integersList.stream();
//        数组创建Stream流，使用Arrays.stream(数组)或者Stream.of()
        Integer[] arr = {1, 2, 3, 4, 5};
        Stream<Integer> arrStream1 = Arrays.stream(arr);
        Stream<Integer> arrStream2 = Stream.of(arr);
//        双列集合创建stream流，先转换成单列集合再创建
        HashMap<String, Integer> stringIntegerHashMap = new HashMap<>();
        stringIntegerHashMap.put("key1", 1);
        stringIntegerHashMap.put("key2", 2);
        stringIntegerHashMap.put("key3", 3);
        Set<Map.Entry<String, Integer>> entrySet = stringIntegerHashMap.entrySet();
        Stream<Map.Entry<String, Integer>> entryStream = entrySet.stream();
        Set<String> keySet = stringIntegerHashMap.keySet();
        Stream<String> keyStream = keySet.stream();
    }
}
